#!/bin/bash

#this file delete the weight info in the related questions files!
#input file format:
#id1    id2@0.2,id3@0.1
#output file format:
#id1    id2,id3
if [ $# -lt 1 ] 
then
    echo "Usage: ./deleteWeight.sh srcFile";
    echo "File structure:"
    echo "id1""\t""id2,id3,id4"
    exit 1;
else
    src_file=$1
fi

awk '{
    idNum = split($2, relates, ",");
    tmpStr="";
    for (id=1; id<=idNum; ++id) {
        if (length(relates[id]) < 1) continue;
        split(relates[id], itemInfo, "@");
#print relates[id],itemInfo[1];
        if (1 == id) tmpStr = itemInfo[1];
        else tmpStr = tmpStr","itemInfo[1];
    }
    print $1,tmpStr;
}' $src_file
